﻿using LNet;
using OestsCommon.Model;
using OestsDataBase;
using OestsServer.Net;
using System.Collections.Generic;

/// <summary>
/// 静态请求名称空间，请求后移除对该类型的监听
/// </summary>
namespace OestsServer.Handlers.OESPHandlers
{
    /// <summary>
    /// 处理请求表数据
    /// </summary>
    public class AreaTableHandler : HandlerBase<OESPClientChannel>
    {
        public override PacketKey PKey
        {
            get
            {
                return PacketKey.AreaTable;
            }
        }

        public override void Execute(OESPClientChannel client, Request packet)
        {

            base.Execute(client, packet);
            //读取数据库
            List<AreaModel> list = AreaDAL.GetData();
            ResponsePacket.DataObject = list;
            client.Send(ResponsePacket);
        }
    }

    /// <summary>
    /// 处理请求表数据
    /// </summary>
    public class MajorTableHandler : HandlerBase<OESPClientChannel>
    {
        public override PacketKey PKey
        {
            get
            {
                return PacketKey.MajorTable;
            }
        }

        public override void Execute(OESPClientChannel client, Request packet)
        {
            base.Execute(client, packet);
            //读取数据库
            List<MajorModel> list = MajorDAL.GetData();
            ResponsePacket.DataObject = list;
            client.Send(ResponsePacket);
        }
    }

    /// <summary>
    /// 处理请求表数据
    /// </summary>
    public class PostTableHandler : HandlerBase<OESPClientChannel>
    {
        public override PacketKey PKey
        {
            get
            {
                return PacketKey.PostTable;
            }
        }
        public override void Execute(OESPClientChannel client, Request packet)
        {
            base.Execute(client, packet);

            //读取数据库
            List<PostModel> list = PostDAL.GetAllPost();
            ResponsePacket.DataObject = list;
            client.Send(ResponsePacket);
        }
    }
    /// <summary>
    /// 处理请求表数据
    /// </summary>
    public class PostTaskTableHandler : HandlerBase<OESPClientChannel>
    {
        public override PacketKey PKey
        {
            get
            {
                return PacketKey.PostTaskTable;
            }
        }

        public override void Execute(OESPClientChannel client, Request packet)
        {
            base.Execute(client, packet);

            //读取数据库
            List<PostTaskModel> list = PostTaskDAL.GetData();
            ResponsePacket.DataObject = list;
            client.Send(ResponsePacket);
        }
    }

    /// <summary>
    /// 处理请求表数据
    /// </summary>
    public class ProjectTableHandler : HandlerBase<OESPClientChannel>
    {
        public override PacketKey PKey
        {
            get
            {
                return PacketKey.ProjectTable;
            }
        }

        public override void Execute(OESPClientChannel client, Request packet)
        {
            base.Execute(client, packet);

            //读取数据库
            List<ProjectModel> listtask = ProjectDAL.GetData();
            ResponsePacket.DataObject = listtask;
            client.Send(ResponsePacket);

        }
    }



    public class TaskTableHandler : HandlerBase<OESPClientChannel>
    {
        /*管理系统 请求所有项目的任务表*/
        public override PacketKey PKey => PacketKey.TaskTable;

        public override void Execute(OESPClientChannel client, Request resquestPacket)
        {
            //DP<int, int> data = JsonMapper.ToObject<DP<int, int>>(resquestPacket.DataStr);
            //int projectId = data.Value1;
            //int teachId = data.Value2;
            base.Execute(client, resquestPacket);
            List<TaskModel> list = TaskDAL.GetAllProjectTask();
            ResponsePacket.DataObject = list;
            client.Send(ResponsePacket);
        }
    }



    public class ClassTableHandler : HandlerBase<OESPClientChannel>
    {

        public override PacketKey PKey => PacketKey.ClassTable;

        public override void Execute(OESPClientChannel client, Request packet)
        {
            base.Execute(client, packet);

            List<ClassModel> list = ClassDAL.GetData();
            ResponsePacket.DataObject = list;
            client.Send(ResponsePacket);
        }
    }

    public class StudentClassTableHandler : HandlerBase<OESPClientChannel>
    {
        public override PacketKey PKey => PacketKey.StudentClassTable;

        public override void Execute(OESPClientChannel client, Request packet)
        {
            base.Execute(client, packet);

            List<StudentClass> list = StudentClassDAL.GetData();
            ResponsePacket.DataObject = list;
            client.Send(ResponsePacket);
        }
    }




    public class ProjectPostTableHandler : HandlerBase<OESPClientChannel>
    {
        public override PacketKey PKey
        {
            get
            {
                return PacketKey.ProjectPostTable;
            }
        }
        public override void Execute(OESPClientChannel client, Request packet)
        {
            base.Execute(client, packet);

            //读取数据库
            List<ProjectPostModel> list = ProjectPostDAL.GetData();
            ResponsePacket.DataObject = list;
            client.Send(ResponsePacket);
        }
    }
}
